<template>
  <div class="wholesale-list block">
    <div class="header">
      <h2 class="title">报台日期配置</h2>
      <tabs :isHiddenZero="true" :tabs-arr="tabArr" :activeIndex="activeIndex" @returnIndex="handletabs" />
      <el-form ref="queryForm" :inline="true" label-position="right" :model="tableQuery">
        <el-form-item label="原厂" prop="supplierName">
          <el-select
            v-model="tableQuery.originalFactoryCode"
            filterable
            remote
            clearable
            placeholder="请输入关键词"
            :remote-method="queryOriginalFactoryList"
            @change="queryProductLineList()"
            :loading="loading">
            <el-option
              v-for="item in originalFactoryList"
              :key="item.originalFactoryCode"
              :label="item.originalFactoryName"
              :value="item.originalFactoryCode"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="产品线">
          <el-select
            v-model="tableQuery.productLineCode"
            filterable
            remote
            clearable
            :disabled="!tableQuery.originalFactoryCode"
            placeholder="请输入关键词"
            :remote-method="queryProductLineList"
            :loading="loading">
            <el-option
              v-for="item in productLineList"
              :key="item.productLineCode"
              :label="item.productLineName"
              :value="item.productLineCode"
            />
          </el-select>
        </el-form-item>

        <el-form-item class="form-button">
          <el-button type="primary" @click="queryFormQuery(true)">查询</el-button>
          <el-button @click="queryFormReset">重置</el-button>
        </el-form-item>
        <div class="clear"></div>
      </el-form>
    </div>
    <section class="el-container container-box is-vertical">
      <div class="table-tips">
        <span v-if="newspaperDateConfigType === 1">注：产品线未设置报台截止日期时，默认报台截止日期为当月最后一天</span>
        <span v-else>注：设置临时日期后，会优先按照临时日期设置的时间计算报台日期</span>
      </div>
      <div class="operate">
        <el-button type="primary" size="mini" @click="onAdd('fixed')">新增固定日期</el-button>
        <el-button type="primary" size="mini" @click="onAdd('temporary')">新增临时日期</el-button>
<!--        <el-button type="primary" size="mini" @click="exportEx">部分导出</el-button>-->
<!--        <el-button type="primary" size="mini" @click="exportExAll">全部导出</el-button>-->
      </div>
      <el-editable
        row-key="orderId"
        :data="payload.content"
        height="400"
        stripe
        ref="tableRef"
        v-loading="tableLoading"
        :columns="listColumns"
        :payload="payload"
        :needPagination="true"
        @reload="reloadProductData"
        @selection-change="selectionChange"
      >
        <template slot="default-operation" slot-scope="scope">
          <el-button size="small"
                     type="text text-primary"
                     @click.stop="onEdit(scope.row)"
          >编辑</el-button>
          <el-button size="small"
                     type="text text-primary"
                     @click.stop="onDelete(scope.row)"
          >删除</el-button>
        </template>
      </el-editable>
    </section>
  </div>
</template>

<script src="./index.js"></script>

<style lang="less" src="./index.less" scoped></style>
